//
//  SectionedListDataContainerTests.m
//  UKListManager
//
//  Created by ET|冰琳 on 16/11/3.
//  Copyright © 2016年 UK. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "UKSectionedListDataContainer.h"
#import "UKSectionAItemListDataContainer.h"
#import "UKSingleSectionListDataContainer.h"


@interface SectionedListDataContainerTests : XCTestCase

@end

@implementation SectionedListDataContainerTests

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testSectionedListDataContainerExample {
    
    UKSectionedListDataContainer *sectioned = [UKSectionedListDataContainer new];
    NSInteger section = [sectioned sectionCount];
    
    // row count without data
    NSInteger rowCount = [sectioned rowCountAtSection:0];
    XCTAssertEqual(rowCount, 0);
    
    [sectioned.listData addObject:@[@"1", @"2", @"3"]];
    [sectioned.listData addObject:@[@"1", @"2"]];
    NSInteger sectionAdd = [sectioned sectionCount];
    NSInteger rowCountAdd = [sectioned rowCountAtSection:0];
    
    //row count
    XCTAssertEqual(rowCountAdd, 3);
    
    //section count
    XCTAssertEqual(section, 0);
    XCTAssertEqual(sectionAdd, 2);
    
    //data
    
    NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0];
    NSString *item_index = [sectioned dataAtIndexPath:index];
    XCTAssertEqual(item_index, @"1");
}


- (void)testUKSectionAItemListDataContainerTest{
    UKSectionAItemListDataContainer *container = [UKSectionAItemListDataContainer new];
    
    NSInteger emptyRow = [container rowCountAtSection:0];
    XCTAssertEqual(emptyRow, 0);
    
    [container.listData addObject:@"1"];
    [container.listData addObject:@"2"];
    
    NSInteger sectionCount = [container rowCountAtSection:0];
    XCTAssertEqual(sectionCount, 1);
    
    NSInteger twoSection = [container sectionCount];
    XCTAssertEqual(twoSection, 2);
    
    //data
    
    NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:1];
    NSString *item_index = [container dataAtIndexPath:index];
    XCTAssertEqual(item_index, @"2");
    
}


- (void)testSingleSectionListDataContainerTest{
    
    UKSingleSectionListDataContainer *container = [UKSingleSectionListDataContainer new];
    
    
    NSInteger emptyRow = [container rowCountAtSection:0];
    XCTAssertEqual(emptyRow, 0);
    
    NSInteger emptySec = [container sectionCount];
    XCTAssertEqual(emptySec, 0);
    
    [container.listData addObject:@"1"];
    [container.listData addObject:@"2"];
    
    NSInteger twoRow = [container rowCountAtSection:0];
    XCTAssertEqual(twoRow, 2);
    
    NSInteger tworowSecCount = [container sectionCount];
    XCTAssertEqual(tworowSecCount, 1);
    
    //data
    
    NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0];
    NSString *item_index = [container dataAtIndexPath:index];
    XCTAssertEqual(item_index, @"2");
}



@end
